// BartalChatAdvanced.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "Server.h"
#include "Client.h"
#include <iostream>
#include <string>
#include "MyArray.h"

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	char input;
	cout << "Welcome to BartalChatAdvanced" << endl;
	while(true) {
		cout << "What do you want to run ?" << endl;
		cout << "1) Server" << endl;
		cout << "2) Client" << endl;
		cout << "x) Exit" << endl;
		cin >> input;
		
		if(input == '1') {
			Server server;
			server.start(4444);
		} else if(input == '2') {
			string nick;
			string ip;
			cout << endl;
			cout << "Server IP (127.0.0.1 = localhost): ";
			cin >> ip;
			cout << endl;
			cout << endl;
			cout << "Input nick: ";
			cin >> nick;
			Client client(nick);
			client.ConnectToServer(ip.c_str(),4444);
		} else if(input == 'x') {
			break;
		} else {		
			cout <<  endl;
			cout << "Invalid input: " << input << ". Please try again" << endl;
		}
	}
	return 0;
}